<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function getText(url,callback) {
            var request =new XMLHttpRequest();
            request.open("GET",url);
            request.onreadystatechange = function() {
                // 如果请求成功，则它是成功的
                if(request = readyState === 4 && request.status === 200) {
                    var type = request.getResponseHeader("Content-Type");
                    if(type.match(/^text/))
                        callback(request.responseText);
                }
                3
            };
            console.log(request);
            request.status(null);
        }
        getText("https://www.baidu.com")
    </script>
</body>
</html>